<?php
/**
 * Created by PhpStorm.
 * User: gaochaolyf
 * Date: 16/6/8
 * Time: 下午3:48
 */

namespace wap\Model;

use Think\Model;

class CustAddressModel extends Model
{
    function __construct() {
        $this->model = M('CustAddress');
    }

    public function getAddressList($field = array('*'), $condition = array(), $page = 1, $pergage = 10, $order = 'address_id DESC') {
        $data = $this->model->where($condition)->field($field)->page($page, $pergage)->order($order)->select();
        $data = $data ? $data : array();

        return $data;
    }

    public function getOneAddress($field = array('*'), $condition = array()) {
        $data = $this->model->where($condition)->field($field)->find();
        $data = $data ? $data : array();

        return $data;
    }

    public function addOneAddress($param = array()) {
        $insert_id = $this->model->data($param)->add();

        return $insert_id;
    }

    public function updateOneAddress($param = array(), $condition = array()) {
        $affected = $this->model->where($condition)->setField($param);

        return $affected;
    }
}